<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="js/http.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<body>
  <p class="bar">
    <label >导航栏</label>
    <span onclick="location.href='login.html'">登录页</span>
    <span onclick="location.href='register.html'">注册页</span>
    <span onclick="location.href='welcome.html'">欢迎页</span>
  </p>
  <form>
    <p>邮箱：<input name="email" /></p>
    <p>密码：<input name="password" type="password" /></p>
    <p>
      <span class="btn" onclick="login()">登录</span>
    </p>
    <p>
      <span class="btn" onclick="register()">注册</span>
    </p>
  </form>
  
</body>
<script>
function register(){
  location.href = 'register.html'
}
function login(){
  let email = $('input[name="email"]')[0].value
  let password = $('input[name="password"]')[0].value
  ajax(`/api/user/login/${email}/${password}`,(res)=>{
    if(res === email){
      location.href = 'welcome.html'
    }else{
      alert(res)
    }
  },(res)=>{
    if(res === email){
      location.href = 'welcome.html'
    }else{
      alert(res)
    }
  })
}
</script>
</html>